# This sample code uses the Appium python client v2
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy

# For W3C actions
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_input import PointerInput

caps = {}
caps["platformName"] = "Android"
caps["appium:deviceName"] = "gxx"
caps["appium:appPackage"] = "com.xueqiu.android"
caps["appium:appActivity"] = ".view.WelcomeActivityAlias"
caps["appium:autoGrantPermissions"] = "true"
caps["appium:ensureWebviewsHavePages"] = True
caps["appium:nativeWebScreenshot"] = True
caps["appium:newCommandTimeout"] = 3600
caps["appium:connectHardwareKeyboard"] = True

driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)

el1 = driver.find_element(by=AppiumBy.ID, value="com.xueqiu.android:id/tv_agree")
el1.click()

driver.implicitly_wait(6)

el5 = driver.find_element(by=AppiumBy.ID, value="com.xueqiu.android:id/home_search")
el5.click()

driver.implicitly_wait(10)

# TouchAction(driver).long_press().move_to().release().perform()
# driver.swipe()

el6 = driver.find_element(by=AppiumBy.ID, value="com.xueqiu.android:id/search_input_text")
el6.click()
el6.send_keys("alibaba")

driver.implicitly_wait(3)

driver.quit()